package com.edu.service.impl;
/*
 * @Author:princess
 * @Date 2023/11/7 11 07 19:25
 *
 */

import com.edu.bean.Shop;
import com.edu.mapper.GoodsMapper;
import com.edu.mapper.ShopMapper;
import com.edu.service.ShopService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ShopServiceImpl implements ShopService {
    @Resource
    private ShopMapper shopMapper;
    @Resource
    private GoodsMapper goodsMapper;

    @Override
    public int insertShop(Shop shop) {
        return shopMapper.insertShop(shop);
    }

    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int deleteById(int id1,int id2) {
        if (id1 == id2){
            shopMapper.deleteById(id1);
            goodsMapper.deleteById(id2);
        }else{
            return -1;
        }
        return 1;
    }

    @Override
    public List<Shop> selectAllShopByLike(String shopName) {
        return shopMapper.selectAllShopByLike(shopName);
    }
}
